package Day2025_03_14;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class LeetCode139 {
    public boolean wordBreak(String s, List<String> w) {
        int n = s.length();
        boolean[] dp = new boolean[n + 1];
        s = " " + s;
        dp[0] = true;
        Set<String> hash = new HashSet<>(w);
        for (int i = 1; i <= n; i++) {
            for (int j = i; j > 0 ; j--) {
                String ss = s.substring(j, i + 1);
                if (dp[j - 1] == true && hash.contains(ss)) dp[i] = true;
            }
        }
        return dp[n];
    }
    public static void main(String[] args) {
        String s = "asdf";
        System.out.println(s.substring(0, 1));
    }
}
